package com.example.webdriveddd.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

@Data
public class FolderDTO {
    private int folderId;
    private String folderName;
    private String folderPath;
    private int parentId;
    private int userId;
    private boolean shared;
    private String description;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime uploadTime;
    private Set<FileInfoDTO> subFiles=new HashSet<>();

    public boolean equals(Object other){
        if(other instanceof FolderDTO otherFolder){
            if (this.folderId==otherFolder.folderId){
                return true;
            }
            if(this.folderName.equals(otherFolder.folderName)&&this.parentId==otherFolder.parentId&&this.userId==otherFolder.userId){
                return true;
            }
            return false;
        }
        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(folderName, parentId, userId);
    }
}
